import type { IQuery, TableResponse } from '@/api/config/types';
import axios from 'axios'; // 确保你导入了正确的 axios 实例或配置

export interface QueueItem {
  queueId: string;
  tagCode: string;
  goodsId: string;
  goodsName: string;
  barCode: string;
  retailPrice: number;
  stationNum: string;
  sendTime: string;
  doneTime: string | null;
  packetSn: number;
  status: string;
  retryTimes: number | null;
  resolutionId: string;
  deptId: string;
  err: any;
  resolutionDesc: string;
}
export interface QueueGroup {
  total: number;
  suc: number;
  timeout: number;
  wait: number;
  createTime: string;
  batchName: string;
  triggerType: string;
  deptId: string;
  storeName: string;
}

const prefix = '/sendqueue/sendqueue';

export const listSendqueue = (query?: IQuery) => {
  return axios.get(`${prefix}/list`, { params: query });
};

export const delSendqueue = (queueId: Array<string>) => {
  return axios.delete(`${prefix}/${queueId.join(',')}`);
};

export const reissue = (queueId: string) => {
  return axios.put(`${prefix}/reissue/${queueId}`);
};

export const batchReissue = (batch: string) => {
  return axios.get(`${prefix}/reissue/batch`, { params: { batch } });
};

export const groupsList = (query?: IQuery) => {
  return axios.get<TableResponse<QueueGroup>>(`${prefix}/groupsList`, { params: query });
};

export const reissueByTime = (type: 'min' | 'hour' | 'day', value: number) => {
  return axios.get(`${prefix}/reissue`, { params: { type, value } });
};
